const Model = require('sqltool/src/model')
const sqltool = require('sqltool')

class TokenModel extends Model {
  getValidToken (token) {
    return this.findOne({
      attrs: ['userId', 'expireAt'],
      where: {
        token: token,
        expireAt: sqltool.Op.gte(new Date())
      }
    })
  }
}

module.exports = TokenModel
